package com.apache.rpc.client.protocol;

import java.util.Map;

import com.apache.api.vo.ResultEntity;
import com.apache.rpc.entity.InterfaceRegister;
import com.apache.rpc.entity.Protocol;
import com.apache.rpc.util.XMLMapParse;

public abstract class AbstractProtocolClient {

	public abstract ResultEntity doService(String beanId, String methodKey, Map<String, Object> params);

	protected InterfaceRegister register;

	protected String buildXml(String beanId, String methodKey, String protocolType, Map<String, Object> params) {
		Protocol pt = new Protocol();
		pt.setBeanId(beanId);
		pt.setParams(params);
		pt.setReqFlag(methodKey);
		pt.setProtocolType(protocolType);
		pt.setRespType("xml");
		return XMLMapParse.instance().buildSingleXML(pt);
	}

	protected ResultEntity getResultEntity(String message) {
		ResultEntity resultEntity = new ResultEntity();
		resultEntity.setResult("false");
		resultEntity.setMessage(message);
		//resultEntity.setEntity("");
		return resultEntity;
	}

	public void setRegister(InterfaceRegister register) {
		this.register = register;
	}

}
